package com.sh.data.engine.job.admin.core.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * Created by xuxueli on 16/9/30.
 */
@TableName("xxl_job_group")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class XxlJobGroup extends Model<XxlJobGroup> {

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    @TableField(value = "app_name")
    private String appname;
    private String title;
    private int addressType; // 执行器地址类型：0=自动注册、1=手动录入
    private String addressList; // 执行器地址列表，多地址逗号分隔(手动录入)
    private Date updateTime;

    // registry list
    @TableField(exist = false)
    private List<String> registryList; // 执行器地址列表(系统注册)

    public List<String> getRegistryList() {
        if (addressList != null && addressList.trim().length() > 0) {
            registryList = new ArrayList<>(Arrays.asList(addressList.split(",")));
        }

        return registryList;
    }
}
